<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>File Source for ThumbLib.inc.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
						<h1>Source for file ThumbLib.inc.php</h1>
<p>Documentation is available at <a href="../PhpThumb/_clientResources---php---others---phpThumb---ThumbLib.inc.php.html">ThumbLib.inc.php</a></p>
<div class="src-code">
<div class="src-code"><ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">&nbsp;*&nbsp;PhpThumb&nbsp;Library&nbsp;Definition&nbsp;File</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;This&nbsp;file&nbsp;contains&nbsp;the&nbsp;definitions&nbsp;for&nbsp;the&nbsp;PhpThumbFactory&nbsp;class.</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*&nbsp;It&nbsp;also&nbsp;includes&nbsp;the&nbsp;other&nbsp;required&nbsp;base&nbsp;class&nbsp;files.</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-doc">&nbsp;*&nbsp;If&nbsp;you've&nbsp;got&nbsp;some&nbsp;auto-loading&nbsp;magic&nbsp;going&nbsp;on&nbsp;elsewhere&nbsp;in&nbsp;your&nbsp;code,&nbsp;feel&nbsp;free&nbsp;to</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-doc">&nbsp;*&nbsp;remove&nbsp;the&nbsp;include_once&nbsp;statements&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;this&nbsp;file...&nbsp;just&nbsp;make&nbsp;sure&nbsp;that</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-doc">&nbsp;*&nbsp;these&nbsp;files&nbsp;get&nbsp;included&nbsp;one&nbsp;way&nbsp;or&nbsp;another&nbsp;in&nbsp;your&nbsp;code.</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-doc">&nbsp;*&nbsp;PHP&nbsp;Version&nbsp;5&nbsp;with&nbsp;GD&nbsp;2.0+</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-doc">&nbsp;*&nbsp;PhpThumb&nbsp;:&nbsp;PHP&nbsp;Thumb&nbsp;Library&nbsp;&lt;http://phpthumb.gxdlabs.com&gt;</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-doc">&nbsp;*&nbsp;Copyright&nbsp;(c)&nbsp;2009,&nbsp;Ian&nbsp;Selby/Gen&nbsp;X&nbsp;Design</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-doc">&nbsp;*&nbsp;Author(s):&nbsp;Ian&nbsp;Selby&nbsp;&lt;ian@gen-x-design.com&gt;</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-doc">&nbsp;*&nbsp;Licensed&nbsp;under&nbsp;the&nbsp;MIT&nbsp;License</span></div></li>
<li><div class="src-line"><a name="a19"></a><span class="src-doc">&nbsp;*&nbsp;Redistributions&nbsp;of&nbsp;files&nbsp;must&nbsp;retain&nbsp;the&nbsp;above&nbsp;copyright&nbsp;notice.</span></div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a21"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@author</span><span class="src-doc">&nbsp;Ian&nbsp;Selby&nbsp;&lt;ian@gen-x-design.com&gt;</span></div></li>
<li><div class="src-line"><a name="a22"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@copyright</span><span class="src-doc">&nbsp;Copyright&nbsp;(c)&nbsp;2009&nbsp;Gen&nbsp;X&nbsp;Design</span></div></li>
<li><div class="src-line"><a name="a23"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;http://phpthumb.gxdlabs.com</span></div></li>
<li><div class="src-line"><a name="a24"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@license</span><span class="src-doc">&nbsp;http://www.opensource.org/licenses/mit-license.php&nbsp;The&nbsp;MIT&nbsp;License</span></div></li>
<li><div class="src-line"><a name="a25"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@version</span><span class="src-doc">&nbsp;3.0</span></div></li>
<li><div class="src-line"><a name="a26"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;PhpThumb</span></div></li>
<li><div class="src-line"><a name="a27"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@filesource</span></div></li>
<li><div class="src-line"><a name="a28"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a29"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a30"></a><span class="src-comm">//&nbsp;define&nbsp;some&nbsp;useful&nbsp;constants</span></div></li>
<li><div class="src-line"><a name="a31"></a><a href="http://www.php.net/define">define</a><span class="src-sym">(</span><span class="src-str">'THUMBLIB_BASE_PATH'</span><span class="src-sym">,&nbsp;</span><span class="src-id">dirname</span><span class="src-sym">(</span>__FILE__<span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a32"></a><a href="http://www.php.net/define">define</a><span class="src-sym">(</span><span class="src-str">'THUMBLIB_PLUGIN_PATH'</span><span class="src-sym">,&nbsp;</span><span class="src-id">THUMBLIB_BASE_PATH&nbsp;</span>.&nbsp;<span class="src-str">'/thumb_plugins/'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a33"></a><a href="http://www.php.net/define">define</a><span class="src-sym">(</span><span class="src-str">'DEFAULT_THUMBLIB_IMPLEMENTATION'</span><span class="src-sym">,&nbsp;</span><span class="src-str">'gd'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a34"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a35"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a36"></a><span class="src-doc">&nbsp;*&nbsp;Include&nbsp;the&nbsp;PhpThumb&nbsp;Class</span></div></li>
<li><div class="src-line"><a name="a37"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a38"></a><span class="src-inc">require_once&nbsp;</span><span class="src-id">THUMBLIB_BASE_PATH&nbsp;</span>.&nbsp;<span class="src-str">'/PhpThumb.inc.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a39"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a40"></a><span class="src-doc">&nbsp;*&nbsp;Include&nbsp;the&nbsp;ThumbBase&nbsp;Class</span></div></li>
<li><div class="src-line"><a name="a41"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a42"></a><span class="src-inc">require_once&nbsp;</span><span class="src-id">THUMBLIB_BASE_PATH&nbsp;</span>.&nbsp;<span class="src-str">'/ThumbBase.inc.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a43"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a44"></a><span class="src-doc">&nbsp;*&nbsp;Include&nbsp;the&nbsp;GdThumb&nbsp;Class</span></div></li>
<li><div class="src-line"><a name="a45"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a46"></a><span class="src-inc">require_once&nbsp;</span><span class="src-id">THUMBLIB_BASE_PATH&nbsp;</span>.&nbsp;<span class="src-str">'/GdThumb.inc.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a47"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a48"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a49"></a><span class="src-doc">&nbsp;*&nbsp;PhpThumbFactory&nbsp;Object</span></div></li>
<li><div class="src-line"><a name="a50"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a51"></a><span class="src-doc">&nbsp;*&nbsp;This&nbsp;class&nbsp;is&nbsp;responsible&nbsp;for&nbsp;making&nbsp;sure&nbsp;everything&nbsp;is&nbsp;set&nbsp;up&nbsp;and&nbsp;initialized&nbsp;properly,</span></div></li>
<li><div class="src-line"><a name="a52"></a><span class="src-doc">&nbsp;*&nbsp;and&nbsp;returning&nbsp;the&nbsp;appropriate&nbsp;thumbnail&nbsp;class&nbsp;instance.&nbsp;&nbsp;It&nbsp;is&nbsp;the&nbsp;only&nbsp;recommended&nbsp;way</span></div></li>
<li><div class="src-line"><a name="a53"></a><span class="src-doc">&nbsp;*&nbsp;of&nbsp;using&nbsp;this&nbsp;library,&nbsp;and&nbsp;if&nbsp;you&nbsp;try&nbsp;and&nbsp;circumvent&nbsp;it,&nbsp;the&nbsp;sky&nbsp;will&nbsp;fall&nbsp;on&nbsp;your&nbsp;head&nbsp;:)</span></div></li>
<li><div class="src-line"><a name="a54"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a55"></a><span class="src-doc">&nbsp;*&nbsp;Basic&nbsp;use&nbsp;is&nbsp;easy&nbsp;enough.&nbsp;&nbsp;First,&nbsp;make&nbsp;sure&nbsp;all&nbsp;the&nbsp;settings&nbsp;meet&nbsp;your&nbsp;needs&nbsp;and&nbsp;environment...</span></div></li>
<li><div class="src-line"><a name="a56"></a><span class="src-doc">&nbsp;*&nbsp;these&nbsp;are&nbsp;the&nbsp;static&nbsp;variables&nbsp;defined&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the&nbsp;class.</span></div></li>
<li><div class="src-line"><a name="a57"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a58"></a><span class="src-doc">&nbsp;*&nbsp;Once&nbsp;that's&nbsp;all&nbsp;set,&nbsp;usage&nbsp;is&nbsp;pretty&nbsp;easy.&nbsp;&nbsp;You&nbsp;can&nbsp;simply&nbsp;do&nbsp;something&nbsp;like:</span></div></li>
<li><div class="src-line"><a name="a59"></a><span class="src-doc">&nbsp;*&nbsp;&lt;code&gt;$thumb&nbsp;=&nbsp;PhpThumbFactory::create('/path/to/file.png');&lt;/code&gt;</span></div></li>
<li><div class="src-line"><a name="a60"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a61"></a><span class="src-doc">&nbsp;*&nbsp;Refer&nbsp;to&nbsp;the&nbsp;documentation&nbsp;for&nbsp;the&nbsp;create&nbsp;function&nbsp;for&nbsp;more&nbsp;information</span></div></li>
<li><div class="src-line"><a name="a62"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a63"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;PhpThumb</span></div></li>
<li><div class="src-line"><a name="a64"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@subpackage</span><span class="src-doc">&nbsp;Core</span></div></li>
<li><div class="src-line"><a name="a65"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a66"></a><span class="src-key">class&nbsp;</span><a href="../PhpThumb/Core/PhpThumbFactory.html">PhpThumbFactory</a></div></li>
<li><div class="src-line"><a name="a67"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a68"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a69"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Which&nbsp;implemenation&nbsp;of&nbsp;the&nbsp;class&nbsp;should&nbsp;be&nbsp;used&nbsp;by&nbsp;default</span></div></li>
<li><div class="src-line"><a name="a70"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a71"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Currently,&nbsp;valid&nbsp;options&nbsp;are:</span></div></li>
<li><div class="src-line"><a name="a72"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;imagick</span></div></li>
<li><div class="src-line"><a name="a73"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;gd</span></div></li>
<li><div class="src-line"><a name="a74"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a75"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;These&nbsp;are&nbsp;defined&nbsp;in&nbsp;the&nbsp;implementation&nbsp;map&nbsp;variable,&nbsp;inside&nbsp;the&nbsp;create&nbsp;function</span></div></li>
<li><div class="src-line"><a name="a76"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a77"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@var&nbsp;</span><span class="src-doc-type">string&nbsp;</span></div></li>
<li><div class="src-line"><a name="a78"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a79"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">static&nbsp;</span><span class="src-var">$defaultImplemenation&nbsp;</span>=&nbsp;<span class="src-id">DEFAULT_THUMBLIB_IMPLEMENTATION</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a80"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a81"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Where&nbsp;the&nbsp;plugins&nbsp;can&nbsp;be&nbsp;loaded&nbsp;from</span></div></li>
<li><div class="src-line"><a name="a82"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a83"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Note,&nbsp;it's&nbsp;important&nbsp;that&nbsp;this&nbsp;path&nbsp;is&nbsp;properly&nbsp;defined.&nbsp;&nbsp;It&nbsp;is&nbsp;very&nbsp;likely&nbsp;that&nbsp;you'll</span></div></li>
<li><div class="src-line"><a name="a84"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;have&nbsp;to&nbsp;change&nbsp;this,&nbsp;as&nbsp;the&nbsp;assumption&nbsp;here&nbsp;is&nbsp;based&nbsp;on&nbsp;a&nbsp;relative&nbsp;path.</span></div></li>
<li><div class="src-line"><a name="a85"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a86"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@var&nbsp;</span><span class="src-doc-type">string&nbsp;</span></div></li>
<li><div class="src-line"><a name="a87"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a88"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">static&nbsp;</span><span class="src-var">$pluginPath&nbsp;</span>=&nbsp;<span class="src-id">THUMBLIB_PLUGIN_PATH</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a89"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a90"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a91"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Factory&nbsp;Function</span></div></li>
<li><div class="src-line"><a name="a92"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a93"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;This&nbsp;function&nbsp;returns&nbsp;the&nbsp;correct&nbsp;thumbnail&nbsp;object,&nbsp;augmented&nbsp;with&nbsp;any&nbsp;appropriate&nbsp;plugins.</span></div></li>
<li><div class="src-line"><a name="a94"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;It&nbsp;does&nbsp;so&nbsp;by&nbsp;doing&nbsp;the&nbsp;following:</span></div></li>
<li><div class="src-line"><a name="a95"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;Getting&nbsp;an&nbsp;instance&nbsp;of&nbsp;PhpThumb</span></div></li>
<li><div class="src-line"><a name="a96"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;Loading&nbsp;plugins</span></div></li>
<li><div class="src-line"><a name="a97"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;Validating&nbsp;the&nbsp;default&nbsp;implemenation</span></div></li>
<li><div class="src-line"><a name="a98"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;Returning&nbsp;the&nbsp;desired&nbsp;default&nbsp;implementation&nbsp;if&nbsp;possible</span></div></li>
<li><div class="src-line"><a name="a99"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;Returning&nbsp;the&nbsp;GD&nbsp;implemenation&nbsp;if&nbsp;the&nbsp;default&nbsp;isn't&nbsp;available</span></div></li>
<li><div class="src-line"><a name="a100"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;-&nbsp;Throwing&nbsp;an&nbsp;exception&nbsp;if&nbsp;no&nbsp;required&nbsp;libraries&nbsp;are&nbsp;present</span></div></li>
<li><div class="src-line"><a name="a101"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a102"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">GdThumb&nbsp;</span></div></li>
<li><div class="src-line"><a name="a103"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@uses</span><span class="src-doc">&nbsp;PhpThumb</span></div></li>
<li><div class="src-line"><a name="a104"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc-var">$filename&nbsp;</span><span class="src-doc">The&nbsp;path&nbsp;and&nbsp;file&nbsp;to&nbsp;load&nbsp;[optional]</span></div></li>
<li><div class="src-line"><a name="a105"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a106"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">static&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../PhpThumb/Core/PhpThumbFactory.html#methodcreate">create</a>&nbsp;<span class="src-sym">(</span><span class="src-var">$filename&nbsp;</span>=&nbsp;<span class="src-id">null</span><span class="src-sym">,&nbsp;</span><span class="src-var">$options&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">,&nbsp;</span><span class="src-var">$isDataStream&nbsp;</span>=&nbsp;<span class="src-id">false</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a107"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a108"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;map&nbsp;our&nbsp;implementation&nbsp;to&nbsp;their&nbsp;class&nbsp;names</span></div></li>
<li><div class="src-line"><a name="a109"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$implementationMap&nbsp;</span>=&nbsp;<span class="src-key">array</span></div></li>
<li><div class="src-line"><a name="a110"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a111"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'imagick'&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-str">'ImagickThumb'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a112"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'gd'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-str">'GdThumb'</span></div></li>
<li><div class="src-line"><a name="a113"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a114"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a115"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;grab&nbsp;an&nbsp;instance&nbsp;of&nbsp;PhpThumb</span></div></li>
<li><div class="src-line"><a name="a116"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$pt&nbsp;</span>=&nbsp;<span class="src-id"><a href="../PhpThumb/Core/PhpThumb.html">PhpThumb</a></span><span class="src-sym">::</span><a href="../PhpThumb/Core/PhpThumb.html#methodgetInstance">getInstance</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a117"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;load&nbsp;the&nbsp;plugins</span></div></li>
<li><div class="src-line"><a name="a118"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$pt</span><span class="src-sym">-&gt;</span><span class="src-id">loadPlugins</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$pluginPath</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a119"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a120"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$toReturn&nbsp;</span>=&nbsp;<span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a121"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$implementation&nbsp;</span>=&nbsp;<span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$defaultImplemenation</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a122"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a123"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;attempt&nbsp;to&nbsp;load&nbsp;the&nbsp;default&nbsp;implementation</span></div></li>
<li><div class="src-line"><a name="a124"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$pt</span><span class="src-sym">-&gt;</span><span class="src-id">isValidImplementation</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$defaultImplemenation</span><span class="src-sym">))</span></div></li>
<li><div class="src-line"><a name="a125"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a126"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$imp&nbsp;</span>=&nbsp;<span class="src-var">$implementationMap</span><span class="src-sym">[</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$defaultImplemenation</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a127"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$toReturn&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-var">$imp</span><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">,&nbsp;</span><span class="src-var">$options</span><span class="src-sym">,&nbsp;</span><span class="src-var">$isDataStream</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a128"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a129"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;load&nbsp;the&nbsp;gd&nbsp;implementation&nbsp;if&nbsp;default&nbsp;failed</span></div></li>
<li><div class="src-line"><a name="a130"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else&nbsp;</span><span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$pt</span><span class="src-sym">-&gt;</span><span class="src-id">isValidImplementation</span><span class="src-sym">(</span><span class="src-str">'gd'</span><span class="src-sym">))</span></div></li>
<li><div class="src-line"><a name="a131"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a132"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$imp&nbsp;</span>=&nbsp;<span class="src-var">$implementationMap</span><span class="src-sym">[</span><span class="src-str">'gd'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a133"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$implementation&nbsp;</span>=&nbsp;<span class="src-str">'gd'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a134"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$toReturn&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-var">$imp</span><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">,&nbsp;</span><span class="src-var">$options</span><span class="src-sym">,&nbsp;</span><span class="src-var">$isDataStream</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a135"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a136"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;throw&nbsp;an&nbsp;exception&nbsp;if&nbsp;we&nbsp;can't&nbsp;load</span></div></li>
<li><div class="src-line"><a name="a137"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else</span></div></li>
<li><div class="src-line"><a name="a138"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a139"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id">Exception</span><span class="src-sym">(</span><span class="src-str">'You&nbsp;must&nbsp;have&nbsp;either&nbsp;the&nbsp;GD&nbsp;or&nbsp;iMagick&nbsp;extension&nbsp;loaded&nbsp;to&nbsp;use&nbsp;this&nbsp;library'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a140"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a141"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a142"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$registry&nbsp;</span>=&nbsp;<span class="src-var">$pt</span><span class="src-sym">-&gt;</span><span class="src-id">getPluginRegistry</span><span class="src-sym">(</span><span class="src-var">$implementation</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a143"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$toReturn</span><span class="src-sym">-&gt;</span><span class="src-id">importPlugins</span><span class="src-sym">(</span><span class="src-var">$registry</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a144"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$toReturn</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a145"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a146"></a><span class="src-sym">}</span></div></li>
</ol></div>
</div>
	<p class="notes" id="credit">
		Documentation generated on Fri, 22 Feb 2013 05:34:01 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
	</p>
	</body>
</html>